﻿using Application.DTO.Form;
using Application.DTO;
using Application.IService.Form;
using Domain.Entity.Form;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.OpenApi.Writers;

namespace ApiServer.Controllers.Form
{
    /// <summary>
    /// 表单控制器
    /// </summary>
    [Route("form")]
    [ApiController]
    public class FormController : BaseController<FormDesignInfo>
    {
        private readonly IFormService formService;
        public FormController(IFormService formService):base(formService)
        {
            this.formService = formService;
        }
        /// <summary>
        /// 添加表单数据
        /// </summary>
        /// <returns></returns>
        [HttpPost("add")]
        public async Task<IActionResult> InsertForm(FormDesignerDTO dto)
        {
            return Ok(await formService.InsertForm(dto));
        }
        /// <summary>
        /// 修改表单数据
        /// </summary>
        /// <returns></returns>
        [HttpPut("edit")]
        public async Task<IActionResult> UpdateForm(FormDesignerDTO dto)
        {
            return Ok(await formService.UpdateForm(dto));
        }
        /// <summary>
        /// 删除表单数据
        /// </summary>
        /// <returns></returns>
        [HttpDelete("delete")]
        public async Task<IActionResult> DeleteForm(string ids)
        {
            return Ok(await formService.DeleteForm(ids));
        }
        /// <summary>
        /// 查询表单数据
        /// </summary>
        /// <returns></returns>
        [HttpGet("query")]
        public async Task<IActionResult> ListFormDesigner()
        {
            return Ok(await formService.ListFormDesigner());
        }
    }
}
